﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GtsServer.DAL;
using GtsServer.Model;
using GtsServer.Common;
using System.Data;

namespace GtsServer.Manage.Controller
{
    public class CommunicationController
    {
        CommunicationDAL dal = new CommunicationDAL();
        public List<Communication> GetList(int pageIndex, int pageSize, out int count, string strWhere = "")
        {
            count = 0;
            List<Communication> list = new List<Communication>();
            DataSet ds = dal.GetList(pageIndex, pageSize, strWhere);
            list = IListDataSet.DataSetToIList<Communication>(ds, 0).ToList();
            count = Convert.ToInt32(ds.Tables[1].Rows[0][0]);
            return list;
        }

        public List<Communication> GetList(string strWhere = "")
        {
            List<Communication> list = new List<Communication>();
            DataSet ds = dal.GetList(strWhere);
            list = IListDataSet.DataSetToIList<Communication>(ds, 0).ToList();
            return list;
        }

        public List<Communication> GetListByPID()
        {
            List<Communication> list = new List<Communication>();
            DataSet ds = dal.GetListByID();
            list = IListDataSet.DataSetToIList<Communication>(ds, 0).ToList();
            return list;
        }
        public List<Communication> GetListByID()
        {
            List<Communication> list = new List<Communication>();
            DataSet ds = dal.GetListByID();
            list = IListDataSet.DataSetToIList<Communication>(ds, 0).ToList();
            return list;
        }
        public int Add(Communication models)
        {
            return dal.Add(models);
        }
        public bool Update(Communication model)
        {
            return dal.Update(model);
        }
        public bool Delete(int ID)
        {
            return dal.Delete(ID);
        }
    }
}
